﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace ProjectEuler
{
    internal class Problem16
    {
        public void Solve()
        {
            const int power = 1000;

            var number = "2";
            for (var i = 2; i <= power; i++)
            {
                number = Common.MultBySingleDigit(number, 2);
            }

            Debug.WriteLine("2^{0} = {1}", power, number);
            Debug.WriteLine("Sum of digits = {0}", sumDigits(number));
        }

        

        int sumDigits(IEnumerable<char> num)
        {
            return num.Sum(letter => Int32.Parse(letter.ToString()));
        }
    }
}